<template lang="html" >
	<div class="html_a">
		<div class="header">
			<van-nav-bar
			  title="收银台"
			  left-arrow
			  @click-left="onClickLeft"
			>		
			  <van-icon name="arrow-left" slot="left" color="#000" size="20"/>
		   </van-nav-bar>
	   </div>
	   
	   
	    <div class="body">
		    <div class="wrap">
		   	 <div class="title">订单信息</div>
		   	 <floor53 :data="data"></floor53>
		    </div>

	   
		    <div class="wrap">
			   	<div class="title2">请选择支付方式</div>
		    	<div class="selectWrap" @click="active=2">
		    		<div class="section1"><img src="../../../../static/img/lanhu/76.png" alt="" /></div>
		    		<div class="section2">支付宝</div>
		    		<div class="section3">
		    			<img src="../../../../static/img/lanhu/74.png" alt="" v-if="active==2"/>
		    			<img src="../../../../static/img/lanhu/73.png" alt="" v-else/>
		    		</div>
		    	</div>
		    	<div @click="selectActive">
                    <van-cell title="更多支付" is-link arrow-direction="up" value="" style="padding-left: 0;padding-right: 0;" v-if="showMore"/>			    		
                    <van-cell title="更多支付" is-link arrow-direction="down" value="" style="padding-left: 0;padding-right: 0;" v-else/>	
		    	</div>
		    	<div class="selectWrap" @click="active=3" v-if="showMore">
		    		<div class="section1"><img src="../../../../static/img/lanhu/76.png" alt="" /></div>
		    		<div class="section2">支付宝02</div>
		    		<div class="section3">
		    			<img src="../../../../static/img/lanhu/74.png" alt="" v-if="active==3"/>
		    			<img src="../../../../static/img/lanhu/73.png" alt="" v-else/>
		    		</div>
		    	</div>		    	
	    	
		    	<!--<div class="selectWrap" @click="active=1">
		    		<div class="section1"><img src="../../../../static/img/lanhu2/30.png" alt="" /></div>
		    		<div class="section2">更多支付</div>
		    		<div class="section3">	    			
                       <van-icon name="arrow-down" v-if=""/>
                       <van-icon name="arrow-down" v-if=""/>
		    		</div>
		    	</div>		    	-->
		    </div>
		</div>    

        <div class="footer">
		    <div class="confirm_wrap">
	          <van-button  
	          	:loading="btnLoading" color="#FFD630" @click="confirm" block 
	            style="color: #333;width: 100%;">
	          	确认付款
	          </van-button>	
		    </div>
	    </div>

	</div> 
</template>                                                                

<script>
import Floor53 from '_c/market/floor/floor53.vue'
import {getFun} from '@/api/publicFun.js'	 
let publicFun=getFun()
export default {
	name: 'payInfo',	
	components: {
	   Floor53
	},	
	data() {
       return {        
       	  showMore:false,
       	  active:2,
          ordersId:'',
          userId:'',
          btnLoading:false,
          url1:this.$api+'/marketorderservice/api/v1/market/orders',
          url2:this.$api+'/marketorderservice/api/v1/market/getOrdersById',
          data:{},
          params:{
          	addressId:'',
          	ordersId:'',
          	tuserId:'',
          	userId:''
          }
       }
	}, 
	methods: {
	   // 选择更多支付
	   selectActive(){	 
	   	  this.showMore=!this.showMore
	   	  if(!this.showMore){
	   	  	if(this.active==3){
	   	  		this.active=0
	   	  	}
	   	  }
	   },
	   // 返回的话 回到IM界面  
	   goIm(){
           this.getIm(this.data.goodsId,this.data.suserName,this.userId,this.data.suserId,this.data.goodsImage,this.data.savatar,this.ordersId) 	 
	   },
	   // 确认支付
       confirm(){      
       	  if(this.active==0){
       	  	this.$toast('请选择一个支付方式')
       	  	return false
       	  }
//     	  let str='?addressId='+this.params.addressId+'&ordersId='+this.params.ordersId+'&tuserId='+this.params.tuserId+'&userId='+this.params.userId+'&url='+this.params.url
       	  if(this.active==1){
       	  	return false
       	  }
       	  // 支付宝支付
       	  else if(this.active==2){
       	  	this.btnLoading=true
       	  	this.getAliPay(this.params.addressId,this.params.ordersId,this.params.tuserId,1)
//     	    window.location.href="http://192.168.10.186:30003/services/marketpayservice/api/v1/market/alipay/h5/wap"+str       	  	
       	  }
       	  // 另一个支付宝支付
       	  else if(this.active==3){
       	  	this.btnLoading=true
       	  	this.getAliPay2(this.params.addressId,this.params.ordersId,this.params.tuserId,2)       	  	
       	  }
       },
       getData(){
       	let that=this
       	that.$Axios2.Get(that.url1+'/'+that.ordersId+'/'+that.userId).then(function(res) {	
       		that.data=res.data.orders
       		that.params.addressId=res.data.orders.addressId
       		that.params.ordersId=res.data.orders.ordersId
       		that.params.userId=that.userId
       		that.params.tuserId=res.data.orders.tuserId
       	})       	 
       },
       // Ios未知操作
       payIos(){
       	 // 查询订单状态
       	let that=this
       	that.$Axios2.Get(that.url2+'/'+that.ordersId).then(function(res) {	
            if(res.data.ordersState==2){
            	that.paySuccess()
            }else{
            	that.payError()
            }
       	})       	 
       },
       paySuccess(){
       	  this.btnLoading=false       	         	  
	   	  let hasPay=1
	   	  let arg='[{"ordersId":"'+this.ordersId+'"},{"hasPay":"'+hasPay+'"}]' 
	   	  this.link('/market/orders/details',arg)	
       },
       payError(){
       	  this.btnLoading=false
       	  this.$toast('支付失败')
       }
	},
	mixins:[publicFun],//混入
	mounted() {
		this.ordersId=this.$router.currentRoute.query.ordersId;		
		this.userId=this.$router.currentRoute.query.userId;	
		window.paySuccess = this.paySuccess
		window.payIos = this.payIos
		window.payError = this.payError		
		this.getData()			
	}
}
</script>

<style scoped lang="scss">
.html_a{background: #f8f8f8;height: 100%;width: 100%;position: absolute;display: flex;flex-direction: column;
   .header{height: 50px;}
   .body{flex: 1;overflow: scroll;}
   .footer{height: 55px;box-sizing: border-box;padding:5px 20px;display: flex;align-items: center;background: #fff;}
}
.wrap{margin-top: 10px;background: #fff;padding: 0 20px;
    .title{padding: 20px 0;font-size: 14px;border-bottom: 1px solid #f0f0f0;}
    .title2{color: #999;font-size: 13px;padding: 16px 0;}
	.selectWrap{padding: 15px 0;display: flex;align-items: center;}
	.section1 img{width: 17px;display: block;}
	.section3 img{width: 14px;display: block;}
	.section2{flex: 1;margin-left: 10px;}   
}
.confirm_wrap{background: #fff;flex: 1;}
.van-button__text{color: #333;}
.ysWin{background: #f8f8f8}
</style>